//
//  CellForHotTableView.m
//  echo
//
//  Created by dllo on 16/2/25.
//  Copyright © 2016年 Danny. All rights reserved.
//

#import "CellForHotTableView.h"
#import "ModelForHotVCTableViewCell.h"
#import <SDWebImage/UIButton+WebCache.h>
#import "ModelForHotVCTableViewCell.h"

@implementation CellForHotTableView

- (void)passModelForCell:(NSArray *)arr{
    
    self.arrForData = [NSMutableArray arrayWithArray:arr];
    ModelForHotVCTableViewCell *model1 = [arr objectAtIndex:0];
    ModelForHotVCTableViewCell *model2 = [arr objectAtIndex:1];
    [self.buttonForLeft sd_setBackgroundImageWithURL:[NSURL URLWithString:model1.pic_750] forState:UIControlStateNormal];
    [self.buttonForRight sd_setBackgroundImageWithURL:[NSURL URLWithString:model2.pic_750] forState:UIControlStateNormal];
    
    self.labelForLeft.text = model1.name;
    self.labelForRight.text = model2.name;
    
    NSMutableDictionary *dicForLabel1 = model1.user;
    self.labelForLeftBottom.text = [dicForLabel1 objectForKey:@"name"];
    NSMutableDictionary *dicForLable2 = model2.user;
    self.labelForRightBottom.text = [dicForLable2 objectForKey:@"name"];
    
    [self.buttonForLeft addTarget:self action:@selector(handleButtonHotVCForLeft:) forControlEvents:UIControlEventTouchUpInside];
    [self.buttonForRight addTarget:self action:@selector(handleButtonHotVCForRight:) forControlEvents:UIControlEventTouchUpInside];
}

- (void)handleButtonHotVCForLeft:(UIButton *)button{
    ModelForHotVCTableViewCell *model = [self.arrForData objectAtIndex:0];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"postModelForHotVCLeft" object:nil userInfo:@{@"model":model}];
}

- (void)handleButtonHotVCForRight:(UIButton *)button{
    ModelForHotVCTableViewCell *model = [self.arrForData objectAtIndex:1];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"postModelForHotVCRight" object:nil userInfo:@{@"model":model}];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
